﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GeneralDashboard.ViewModel
{
    public class DataSourceViewModel
    {
        private static Dictionary<Type, string> _cvtDic = new Dictionary<Type, string>
        {
            {typeof(bool),   "B"},
            {typeof(sbyte),  "S8" },
            {typeof(short),  "S" },
            {typeof(int),    "I" },
            {typeof(long),   "L" },
            {typeof(byte),   "U8" },
            {typeof(ushort), "US" },
            {typeof(uint),   "UI"},
            {typeof(ulong),  "UL"},
            {typeof(float),  "F" },
            {typeof(double), "D" },
            {typeof(string), "T" }
        };
        public Type DataType { get; set; }
        public string Title { get; set; }
        public string Source { get; set; }
        public string TypeName => DataType.Name;
        public string TypeTitle
        {
            get
            {
                if (!_cvtDic.ContainsKey(DataType))
                    throw new ArgumentException("不支持的数据类型");
                return _cvtDic[DataType];
            }
        }
    }
}
